package com.red.star.wechat.data.entity;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;

/**
 * 首页访问记录实体
 *
 * @author nofish.yan@gmail.com
 * @date 2018/11/19.
 */
@Data
@NoArgsConstructor
@Table(name = "lg_home_view")
public class HomeViewLog extends BaseEntity {

    /**
     * 商场编码
     */
    private String mallCode;

    /**
     * 访问者小程序粉丝ID
     */
    private Integer fansId;

    /**
     * 访问者小程序OpenId
     */
    private String openId;

    /**
     * 访问来源渠道:normal(正常进入) scan(扫码) share(转发)
     */
    private String channel;

    /**
     * 分享者openId(渠道为分享)
     */
    private String fromOpenId;

    public HomeViewLog(String mallCode, Integer fansId, String openId, String channel, String fromOpenId) {
        this.mallCode = mallCode;
        this.fansId = fansId;
        this.openId = openId;
        this.channel = channel;
        this.fromOpenId = fromOpenId;
        this.createTime = new Date(System.currentTimeMillis());
        this.updateTime = new Date(System.currentTimeMillis());
    }

    /**
     * 阅读pv
     */
    @Transient
    private Integer pv;

    /**
     * 阅读uv
     */
    @Transient
    private Integer uv;

    /**
     * 商场名称
     */
    @Transient
    private String mallName;

    /**
     * 开始时间
     */
    @Transient
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date startTime;

    /**
     * 结束时间
     */
    @Transient
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endTime;
}
